<?php
require_once('settings.php');
$core = new izwebz();
$api = new \Slim\Slim();

$api->get('/',function() use ($core){
	$core->responseData(500,array_merge(array('success'=>false),array('message'=>'The server encountered an error processing your request')));
});

$api->get('/listPosts/:user/:token/',function($user,$token) use ($core,$api){
	$query = $api->request()->get();
	$core->queryPosts($user,$token,$query);
});

$api->get('/getPost/:user/:token/:id/',function($user,$token,$id) use ($core,$api){
	$core->findPost($user,$token,$id);
});

$api->get('/rencentPost/:user/:token/',function($user,$token) use ($core,$api){
	$query = $api->request()->get();
	$core->recentPosts($user,$token,$query);
});

$api->get('/popularPosts/:user/:token/',function($user,$token) use ($core,$api){
	$core->popularPosts($user,$token);
});

$api->run();
